<META HTTP-EQUIV="pragma" CONTENT="no-cache">
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>编辑套卡</title>
  <link rel="stylesheet" href="../../../layui/css/layui.css">
  <script src="../../../layui/layui.js"></script>
    <script type="text/javascript" src="../../../js/jquery-2.1.1.min.js"></script>
    <script type="text/javascript" src="../../../js/main.js"></script>
    <link rel="stylesheet" href="../../../js/zyupload/skins/zyupload-1.0.0.min.css " type="text/css">
    <script type="text/javascript" src="../../../js/zyupload/zyupload-1.0.0.min.js"></script>
</head>
<style type="text/css">
 body{
  height: 100%;
  width: 100%;
 }
 .layui-form-label{width: 130px}
 .btn {
    background-color: #e5e5e5;
    background-image: none;
    filter: none;
    border: 0;
    padding: 7px 14px;
    text-shadow: none;
    font-family: "Segoe UI", Helvetica, Arial, sans-serif;
    font-size: 14px;
    color: #333333;
    cursor: pointer;
    outline: none;
    -webkit-box-shadow: none !important;
    -moz-box-shadow: none !important;
    box-shadow: none !important;
    -webkit-border-radius: 0 !important;
    -moz-border-radius: 0 !important;
    border-radius: 0 !important;
}
.layui-input-inline{width: 214px !important}
</style>

<body>
 <!-- 内容主体区域 -->
 <div class="x-body layui-anim layui-anim-up">
  <div class="layui-fluid">
  
    <form class="layui-form layui-form-pane1" lay-filter="first" >
        <div class="layui-form-item">
        </div>
      <div class="layui-form-item">
          <div class="layui-inline">
         <label class="layui-form-label"><span class="text-error">*</span>套卡名称：</label>
         <div class="layui-input-inline">
          <input name="suiteName" id="suiteName" placeholder="请输入" value="" class="layui-input">
          </div>
          </div>

          <div class="layui-inline" >
              <label class="layui-form-label">包含项目：</label>
              <div class="layui-input-inline">
                  <input name="danxuanFW"  placeholder="请输入"  id="bindingList" value="" class="layui-input">
                  <input name="danxuanFWId"  class="bindingList" type="hidden"  class="layui-input">
                  <input name="times"  id="times" type="hidden"  class="layui-input">
              </div>
              <button class="layui-btn zhekou  checkButton"  name="bindingList" type="button">选择范围</button>
          </div>
      </div>

        <div class="layui-form-item">
        <div class="layui-inline"  id="pricePerTimeType">
            <label class="layui-form-label">市场价格：</label>
            <div class="layui-input-inline">
                <input name="priceMarket" id="priceMarket" placeholder="请输入"  value="" class="layui-input">
            </div>
        </div>
        <div class="layui-inline"  id="priceMarketType">
            <label class="layui-form-label">优惠价格：</label>
            <div class="layui-input-inline">
                <input name="price" id="price" placeholder="请输入"  value="" class="layui-input">
            </div>
        </div>
        </div>
        <div class="layui-form-item">
        <div class="layui-inline"  id="priceType">
            <label class="layui-form-label" id="priceLabel">套卡有效期：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" id="timeExpired" name="timeExpired" placeholder="yyyy-MM-dd">
            </div>

            <!--<div class="layui-input-inline">-->
                <!--<input name="timeExpired" id="timeExpired" placeholder="请输入"  value="" class="layui-input">-->
            <!--</div>-->
        </div>

        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">套卡说明：</label>
            <div class="layui-input-inline">

                <textarea name="description" id="description" placeholder="请输入内容" class="layui-textarea"></textarea>
            </div>
        </div>



        <div class="layui-form-item"  id="img1">
            <label class="layui-form-label">项目照片</label>
            <div class="layui-input-inline uploadHeadImage">
                <div class="layui-upload-drag" id="headImg1">
                    <i class="layui-icon"></i>
                    <p>点击上传图片，或将图片拖拽到此处</p>
                </div>
            </div>
            <div class="layui-input-inline">
                <div class="layui-upload-list">
                    <img class="layui-upload-img headImage" src="" id="demo1" width=200px height=130px>
                    <p id="demoText"></p>
                </div>
            </div>
        </div>

        <div class="layui-form-item"  id="img2">
            <label class="layui-form-label">&nbsp;&nbsp;&nbsp;&nbsp;</label>
            <div class="layui-input-inline uploadHeadImage">
                <div class="layui-upload-drag" id="headImg2">
                    <i class="layui-icon"></i>
                    <p>点击上传图片，或将图片拖拽到此处</p>
                </div>
            </div>
            <div class="layui-input-inline">
                <div class="layui-upload-list">
                    <img class="layui-upload-img headImage" src="" id="demo2" width=200px height=130px>
                    <p id="demoText2"></p>
                </div>
            </div>
        </div>

        <div class="layui-form-item" id="img3">
            <label class="layui-form-label">&nbsp;&nbsp;&nbsp;&nbsp;</label>
            <div class="layui-input-inline uploadHeadImage">
                <div class="layui-upload-drag" id="headImg3">
                    <i class="layui-icon"></i>
                    <p>点击上传图片，或将图片拖拽到此处</p>
                </div>
            </div>
            <div class="layui-input-inline">
                <div class="layui-upload-list">
                    <img class="layui-upload-img headImage" src="" id="demo3" width=200px height=130px>
                    <p id="demoText3"></p>
                </div>
            </div>
        </div>

        <div class="layui-form-item"  id="img4">
            <label class="layui-form-label">&nbsp;&nbsp;&nbsp;&nbsp;</label>
            <div class="layui-input-inline uploadHeadImage">
                <div class="layui-upload-drag" id="headImg4">
                    <i class="layui-icon"></i>
                    <p>点击上传图片，或将图片拖拽到此处</p>
                </div>
            </div>
            <div class="layui-input-inline">
                <div class="layui-upload-list">
                    <img class="layui-upload-img headImage" src="" id="demo4" width=200px height=130px>
                    <p id="demoText4"></p>
                </div>
            </div>
        </div>

        <div class="layui-form-item" id="img5">
            <label class="layui-form-label">&nbsp;&nbsp;&nbsp;&nbsp;</label>
            <div class="layui-input-inline uploadHeadImage">
                <div class="layui-upload-drag" id="headImg5">
                    <i class="layui-icon"></i>
                    <p>点击上传图片，或将图片拖拽到此处</p>
                </div>
            </div>
            <div class="layui-input-inline">
                <div class="layui-upload-list">
                    <img class="layui-upload-img headImage" src="" id="demo5" width=200px height=130px>
                    <p id="demoText5"></p>
                </div>
            </div>
        </div>

        <div class="layui-form-item" id="img6">
            <label class="layui-form-label">&nbsp;&nbsp;&nbsp;&nbsp;</label>
            <div class="layui-input-inline uploadHeadImage">
                <div class="layui-upload-drag" id="headImg6">
                    <i class="layui-icon"></i>
                    <p>点击上传图片，或将图片拖拽到此处</p>
                </div>
            </div>
            <div class="layui-input-inline">
                <div class="layui-upload-list">
                    <img class="layui-upload-img headImage" src="" id="demo6" width=200px height=130px>
                    <p id="demoText6"></p>
                </div>
            </div>
        </div>


        <!--<div id="zyupload" class="zyupload"></div>-->




        <div class="layui-form-item">
            <label class="layui-form-label">是否停用：</label>
            <div class="layui-input-block">
                <input type="checkbox" name="recordStatus"  id="recordStatus" lay-skin="switch"  lay-text="ON|OFF">
            </div>
        </div>

        <div class="layui-form-item" style="margin-left: 140px;">
            <!--<p id="btnGroup" class="pull-right">-->
                <button class="layui-btn save"  lay-submit="" lay-filter="*" >保存</button>
                <button class="layui-btn quxiao" >取消</button>
            <!--</p>-->
        </div>
        <input name="recordId" id="recordId"  type="hidden"  class="layui-input">
        <input name="storeId" id="storeId"  type="hidden"  class="layui-input">
        <!--<input name="picRecordId1" id="picRecordId1" placeholder="请输入"  value="" class="layui-input">-->
        <input name="picRecordId1" id="picRecordId1"  type="hidden"  class="layui-input">
        <input name="picRecordId2" id="picRecordId2"  type="hidden"  class="layui-input">
        <input name="picRecordId3" id="picRecordId3"  type="hidden"  class="layui-input">
        <input name="picRecordId4" id="picRecordId4"  type="hidden"  class="layui-input">
        <input name="picRecordId5" id="picRecordId5"  type="hidden"  class="layui-input">
        <input name="picRecordId6" id="picRecordId6"  type="hidden"  class="layui-input">
        <input name="picList"  class="picList" type="hidden"  class="layui-input">

        <input name="timeCreate" id="timeCreate"  type="hidden" value="" class="timeCreate">
    </form>
  </div>
  </div>
  </body>
  </html>
<script type="text/javascript">

    function parentF(data){
        console.log(data);
        var name = "";
        var idTemp  = "";
        var times= "";

        var arr = data.arr;
        var id   = data.parId;
        console.log("arr+++++++++++++++++++++++++++++++++++++"+arr);
        for(var i=0;i<arr.length;i++){
            var temp =arr[i];
            name = name +temp.value+", ";
            idTemp = idTemp + temp.id+",";
            times = times+temp.times+",";
        }
        console.log("id============================================="+idTemp);
        console.log("times============================================="+times);
        $("#times").val(times);
        $("#"+id).val(name);
        $("."+id).val(idTemp);

    }



    //重新渲染表单

    function renderForm(){

        layui.use('form', function(){

            var form = layui.form;
            form.render();

        });

    }



    function child(data){
        var $ = layui.jquery;


        var recordId=data.recordId;
        $('#recordId').val(recordId);

        var timeCreate=data.timeCreate;
        $('#timeCreate').val(timeCreate);
        var storeId=data.storeId;
        $('#storeId').val(storeId);
        console.log('第一个recordId'+recordId);

        $.ajax({
            url:"/hy/basic/pictures/getPictures",
            type:"get",
            data:{"masterDataId":recordId,"recordType":3,"picType":0},
            async: false,
            dataType:"json",
            success:function(dataJson){
                console.log('返回类别'+dataJson.data.length);

                console.log('返回类别'+dataJson.data);
                var picSize=dataJson.data.length;

                $.each(dataJson.data, function (i, n) {
                    console.log('第几个了'+i);
                    console.log(n.picUrl);
                    console.log('#demo'+i++);
                    $('#demo'+i).attr('src', 'http://localhost:8080'+n.picUrl);
                    console.log('#picRecordId'+i);
                    $('#picRecordId'+i).val(n.recordId);

                    console.log("#picRecordId"+i+"==========++++++++++++++++++++"+$('#picRecordId'+i).val());

                    var  recordId=$("#picRecordId1").val();

                    console.log("JquerRecordId"+recordId);
                });




                renderForm();

                $('#parentSeriesId').val(dataJson.data.parentSeries);
            },
            error:function(){
                alert("驳回异常")
            }
        });






        var suiteName = data.suiteName;
        $('#suiteName').val(suiteName);

        var priceMarket = data.priceMarket;
        $('#priceMarket').val(priceMarket);

        var price = data.price;
        $('#price').val(price);

        var timeExpired = data.timeExpired;
        $('#timeExpired').val(timeExpired);

        var description = data.description;
        $('#description').val(description);











    }




    layui.use(['element', 'layer', 'jquery','form','laydate','upload'], function () {
        var form = layui.form;
        var $ = layui.jquery;
        var laydate=layui.laydate;
        /* function quxiao(){
            alert(111);
        } */
        var $ = layui.jquery,
            upload = layui.upload;


        $(".checkButton").on("click",function(){
            var data = this;
            var name = data.name;

            var dataList={};
            dataList.suiteId=$("#recordId").val();

            console.log('第二个recordId'+$("#recordId").val());
            dataList.salonId=2;
            dataList.name=name;
            layer.open({
                type:2,
                area:[720+'px',500+'px'],
                fix:false,
                offset: '80px',
                maxmin:true,
                shadeClose:true,
                shade:0.4,
                title:'选择包含项目',
                content:['check_bin_service.html'],
                success:function(layero,index){
                    // 获取子页面的iframe
                    var iframe = window['layui-layer-iframe' + index];
                    // 向子页面的全局函数child传参
                    iframe.child(dataList);
                    console.log("成功");
                },
                fail:function(dataList){
                    console.log(dataList);
                }
            })
        })





        form.on('submit(*)', function(data){
            console.log(data.field);

            var dataList = data.field;
            var service = {};

            service.suiteName = dataList.suiteName;
            service.priceMarket = dataList.priceMarket;
            service.price = dataList.price;
            service.timeExpired = dataList.timeExpired;
            service.description = dataList.description;
            service.recordId = dataList.recordId;
            service.storeId = dataList.storeId;
            service.timeCreate=dataList.timeCreate;


            if(dataList.recordStatus=='on'){
                service.recordStatus = 1;
            }else{
                service.recordStatus = 0;
            }

            var itemList = [];

            var serviceIds=dataList.danxuanFWId.split(",");
            var times=dataList.times.split(",");

            for ( var i = 0; i <serviceIds.length-1; i++){
                var obj={}
                obj.serviceId=serviceIds[i];
                obj.times=times[i];
                itemList.push(obj);
            }

            console.log("11111111111111111111111111111111"+dataList.times);
            console.log("000000000000000000000000000000"+$("#times").val());



            var url = '/hy/basic/serviceSuite/updateServiceSuite';
            var picList= $(".picList").val();
            $.ajax({
                type:'POST',
                url:url,
                data:{
                    condition:JSON.stringify(service),
                    picIdList:picList,
                    bindingJson:JSON.stringify(itemList),
                    comeFrom:"PC"
                } ,
                contentType: "application/x-www-form-urlencoded",
                success: function(data){
                    alert("操作成功！");
                    window.parent.location.reload(); //刷新父页面
                    var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                    parent.layer.close(index);  // 关闭layer
                    /* alert("操作成功");
                    if(type=="update"){
                        window.parent.location.reload(); //刷新父页面
                        var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                        parent.layer.close(index);  // 关闭layer
                    }else{
                        window.location.reload();
                        //window.location.href="${basePath}ryOrderConfig/queryList";
                    } */

                    //window.location.href="${basePath}ryOrderConfig/queryList";
                },
                error:function(data){
                    alert("操作失败");
                    console.log(data);
                }
            })
            return false;
        });

    })

    layui.use('laydate', function() {
        var laydate = layui.laydate;
        //常规用法
        laydate.render({
            elem: '#timeExpired'
        });
    });





</script>  